<template>
	<view v-if="scrollTop > 20" class="hui" @click="totop">
		<span class="text">返回<br>顶部</span>
<!-- 		<p style="margin-right: -3rpx;">返顶</p>
		<p style="margin-left: -3rpx;">回部</p> -->
	</view>
</template>

<script>
	export default {
		name:"back-top",
		props: {
			// 需要在使用页面 onPageScroll 传进来
			scrollTop: {
				type: [String, Number], // 指定多种类型
				default: 0
			},
			isClick: {
				type: Boolean,
				default: true
			}
		},
		data() {
			return {
				
			};
		},
		methods:{
			//回到顶部
			totop() {
				if(this.isClick){
					uni.pageScrollTo({
						scrollTop: 0,
						duration: 300
					});
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.hui {
		position: fixed;
		//padding: 5.75px 7.5px;
		width: 39px;
		height: 39px;
		text-align: center;
		display: flex;
		align-items: center;
		right: 16rpx;
		bottom: 154rpx;
		font-size: 18rpx;
		background: #0FA291;
		border-radius: 50%;
		color: white;
		p{
			margin: 0rpx;
			padding: 0rpx;
		}
		span{
			position: absolute;
			top: 50%;
			left: 50%;
			transform: translate(-50%, -50%);
		}

		image {
			width: 46rpx;
			height: 46rpx;
			margin-right: 18rpx;
		}
	}
</style>